<?php
function betin3a( $lotto_id, $bettype, $nums, $rate1, $rate, $money, $betcounts, $backs, $account )
{
    $betmoney = $money * $betcounts;
    $fields = array();
    $fields['lotto_id'] = $lotto_id;
    $fields['createtime'] = systime();
    $fields['bettype'] = $bettype;
    $fields['numbers'] = "'{$money}|{$rate}|{$betcounts}|{$nums}'";
    $fields['line_nums'] = "'{$nums}'";
    $fields['amount'] = $betmoney;
    $fields['rate'] = $rate1;
    $fields['back'] = $backs;
    $fields['account'] = "'".$account."'";
    db_insert( "bet8", $fields );
}

if ( !defined( "IN_OP" ) )
{
    exit( "You can't access this file directly..." );
}
if ( ( $curruser['acl'] < 255 || $curruser['acl'] == 255 && $curruser['prev_id'] != 0 ) && !SubAccountRight( $curruser, 1 ) )
{
    diemsg( "你不是管理者！" );
}
$ui = new UI();
$lotto_id = intval( $_POST['lotto_id'] );
$showType = intval( getvar( "showType" ) );
$gameArr = array( 29 => "五不中", 39 => "六不中", 40 => "七不中", 41 => "八不中", 42 => "九不中", 43 => "十不中", 44 => "十一不中", 45 => "十二不中" );
$count_numArr = array( 29 => 5, 39 => 6, 40 => 7, 41 => 8, 42 => 9, 43 => 10, 44 => 11, 45 => 12 );
if ( !isset( $gameArr[$showType] ) )
{
    $showType = 29;
}
$bettype = $showType;
$count_num = $count_numArr[$bettype];
$num = array();
$numcount = 0;
$i = 1;
while ( $i < 50 )
{
    if ( isset( $_POST["num_".$i] ) )
    {
        $num[] = d2( $i );
        ++$numcount;
    }
    ++$i;
}
$rate1 = $_POST['b21a'] + 0;
$backs = $_POST['b22'] + 0;
$money = intval( $_POST['b23'] );
$account = $_POST['account'];
$rate = $rate1;
$selectid = getvar( "select" ) == "" ? 0 : getvar( "select" );
if ( $numcount != $count_num )
{
    diemsg( "勾选个数错误，走飞失败！" );
    exit();
}
sort( $num );
betin3a( $lotto_id, $bettype, implode( ",", $num ), $rate1, $rate, $money, 1, $backs, $account );
echo "<p>走飞成功！</p>";
echo "<p><input type=button value='回上一页' onclick='history.back()'></p>";
echo "<script>";
echo "setTimeout(\"location.href='op.php?op=admin&fp=unow29&showType={$showType}&select={$selectid}'\",30000);";
echo "</script>";
?>